import React from 'react';
import { Button } from 'antd';
import { debounce } from '../../untils/communFun';
const Hoc = (WrappedComponent) => {
    return class extends React.Component {
        state = {}
        render() {
            const newProps = {
                text: '测试'
            }
            return <WrappedComponent {...this.props} {...newProps} />
        }
    }
}

class WrappedComponent extends React.Component {
    state = {}
    deb =  debounce();
    query = () => {
        this.deb(() => {
            console.log('func 执行了');
        }, 3000)
    }
    render() {
        return (
            <>
                <h2>高阶组件{this.props.text}</h2>
                <Button onClick={this.query}>发请求</Button>
            </>
        )
    }
}

export default Hoc(WrappedComponent);